package com.student.controller;

import com.student.pojo.Ke;
import com.student.service.ClassesService;
import com.student.service.KeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @author 是一个鸽子啊
 * @date 2020/4/14
 * @qq 364826415
 */
@Controller
public class KeController {
    @Autowired
    @Qualifier("KeServiceImpl")
    private KeService keService;
    @Autowired
    @Qualifier("classesServiceImpl")
    private ClassesService classesService;
    @RequestMapping("/queryKe")
    private String queryKe(HttpServletRequest request){
        List<Ke> keList = keService.queryKe();
        request.setAttribute("keList",keList);
        return "/class1-settle";
    }
    @RequestMapping("/queryKeByName")
    private String queryKe(HttpServletRequest request,String keName){
        List<Ke> keList = keService.queryKeByName(keName);
        request.setAttribute("keList",keList);
        return "/class1-settle";
    }
    @RequestMapping("/addKe")
    private String queryKe(HttpServletRequest request,Ke ke){
        keService.addKe(ke);
        List<Ke> keList = keService.queryKe();
        request.setAttribute("keList",keList);
        return "/class1-settle";
    }
    @RequestMapping("/updateKe")
    private String updateKe(Ke ke,HttpServletRequest request){
        keService.updateKe(ke);
        List<Ke> keList = keService.queryKe();
        request.setAttribute("keList",keList);
        return "/class1-settle";
    }
    @RequestMapping("/deleteKe")
    private String deleteKe(String keID,HttpServletRequest request){
        keService.deleteKe(Integer.parseInt(keID));
        List<Ke> keList = keService.queryKe();
        request.setAttribute("keList",keList);
        return "/class1-settle";

    }


}
